/* Turska Framework/UI library (Turs2)
 * Copyright 2003-2008 Jetro Lauha
 * All rights reserved.
 * Web: http://iki.fi/jetro/turska/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of EITHER:
 *   (1) The GNU Lesser General Public License as published by the Free
 *       Software Foundation; either version 2.1 of the License, or (at
 *       your option) any later version. The text of the GNU Lesser
 *       General Public License is included with this library in the
 *       file LICENSE-LGPL.txt.
 *   (2) The BSD-style license that is included with this library in
 *       the file LICENSE-BSD.txt.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
 * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
 *
 * $Id: AppState.h 73 2008-07-07 19:06:57Z jlauha $
 * $Revision: 73 $
 */

#ifndef APPSTATE_H_INCL
#define APPSTATE_H_INCL


enum APPSTATE_ENUM
{
    APPSTATE_DEFAULT_FPS = 60
};


class AppState
{
public:

    AppState() : mFPS(APPSTATE_DEFAULT_FPS),
                 mTime(0), mStartTime(0), mPaused(false) {}
    virtual ~AppState() {}

    virtual bool init() { return true; }
    virtual void deinit() {}

    UI32 getUpdateFPS() { return mFPS; }

    virtual bool update(UI32 time);
    virtual void render(SDL_Surface *screen) = 0;

    virtual void onActivate(UI32 /*time*/) { mTime = mStartTime = 0; mPaused = false; }
    virtual void onDeactivate() {}

    virtual bool onKeyDown(const SDL_keysym &event) { return false; }
    virtual bool onKeyUp(const SDL_keysym &event) { return false; }
    virtual bool onMouseDown(const SDL_MouseButtonEvent &event) { return false; }
    virtual bool onMouseUp(const SDL_MouseButtonEvent &event) { return false; }
    virtual bool onMouseMotion(const SDL_MouseMotionEvent &event) { return false; }
    virtual bool onMouseWheel(I32 direction) { return false; }
    virtual void onFocusLost(const SDL_ActiveEvent &event) {}
    virtual void onFocusGain(const SDL_ActiveEvent &event) {}

protected:

    UI32 mFPS;
    UI32 mTime, mStartTime;
    bool mPaused;
};


#endif // !APPSTATE_H_INCL
